package kr.co.pm.ex;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;

public class CustomerMaster {
	public static void main(String[] args) {
		AbstractApplicationContext context = new AnnotationConfigApplicationContext(BeanConfiguration.class);
		CustomerRepository repository = context.getBean(CustomerRepository.class);
		Customer ky = repository.save(new Customer("안가영", "수원"));
		repository.save(new Customer("이다훈", "범계"));
		//1. 등록 save
//		System.out.println("CUSTOMER DETAILS");
//		
//		Iterable<Customer> customers = repository.findAll();
//		for (Object customer : customers) {
//			System.out.println(customer);
//		}
		//2. 조회 findOne
		Customer customer = repository.findOne(ky.getId());
		System.out.println("고객의 이름은? " + customer.getName());
		
		((AbstractApplicationContext) context).close();
	}
}